-module(dictionary).
-compile(export_all).
	
-define(PAGE_URL,
		"http://wordnet.princeton.edu/perl/webwn?s=").

-define(RSS_URL,
		"http://weblogs.asp.net/nleghari/rss.aspx").

% call inets:start() to initialize the http module
get(Type, Query) ->
	io:format("Query: ~p~n", [Query]),
	Url = build_url(Type, Query),
	io:format("Url: ~s~n", [Url]),
	% handling multiple cases of a function return value
	case http:request(Url) of
		{ok, {_, _, Body}} ->
            B = yaws_parse(Body),
            io:format("Body:~n~p~n", [B]),
            {ehtml, _, [_, {html, _, [{head, _,_},{body,_,{'div', _, Body}}]}]} = B;
		{error, Reason} ->
			io:format("Unable to get web page:~p~n", [Reason])
	end,
	io:format("end").
	
build_url(web, Query) ->
	?PAGE_URL ++ Query;
build_url(rss, _Query) ->
    ?RSS_URL.
    

		

